//==============================================================================
// GenBankEntry.hh
// ----------------------------------------------------------------------------
//
//------------------------------------------------------------------------------
// $Id: $
//------------------------------------------------------------------------------
//
//==============================================================================
//.......1.........2.........3.........4.........5.........6.........7.........8
//

#include "LocalSTL.hh"
#include "Sequence.hh"
#include "ParseUtils.hh"

#ifndef _GENBANK_ENTRY
#define _GENBANK_ENTRY


class GenBankComment{
public:
  string mName;
  string mText;
};

class GenBankLocs{
public:
  int mStart;
  int mEnd;
};

class GenBankFeature{
public:
  string mName;
  vector<GenBankLocs> mLocs;
  vector<GenBankComment> mComments;
  bool   mbComplement;

  void clear(){
	 mLocs.clear();
	 mComments.clear();
	 mbComplement = false;
	 mName = "";
  }

  void Print(ostream &out){
	 cout<<mName<<"\t"<<mbComplement<<endl;
	 for(int i = 0;i< mLocs.size();i++){
		cout<<"\t"<<mLocs[i].mStart<<"..."<<mLocs[i].mEnd<<endl;
	 }
	 for(int i = 0;i< mComments.size();i++){
		cout<<"\t"<<mComments[i].mName<<"="<<mComments[i].mText<<endl;
	 }
  }
};


//------------------------------------------------------------------------------
// * GenBankEntry
//------------------------------------------------------------------------------
// Represents and parses a single GenBankEntry.  Currently parses Human annotated 
// finished sequence entries, as submitted by BCM.  Different submittors have different
// standards for annotating features, thus the caveat.  
//
class GenBankEntry{
public:
  vector<GenBankFeature> mFeatures;
  Sequence mSequence;

  string SequenceField(string &line);
  string ContentField(string &l);
  string KeywordField(string &l);
  
  void ParseComment(string &fComment,GenBankFeature &f);
  void ParseFeatureLocs(string &fLocs,GenBankFeature &f);
  void ParseSequenceFromStream(ifstream &fin,Sequence &Seq);
  void ParseFeatureLines(vector<string>&fLines,GenBankFeature &f);

  bool GetNextFeature(string &fname,int &fIdx,GenBankFeature &F);

  // External
  bool ParseGenBankFile(string &FileName);
  void Print(ostream &out);
  void PrintFeatures(ostream &out,string &fname);
  void clear(){
	 mFeatures.clear();
	 mSequence.clear();
  }
};

#endif

